// 滑动树状图
// import i18n from '@/lang'
export default {
  initOptions: {
    tooltip: {
    },
    legend: {
    },
    xAxis: {
      type: 'category'
    },
    yAxis: [
      {
        type: 'value'
      }
    ],
    series: []
  },
  setEchart (echartObject, legend, series, xAxis) {
    echartObject.setOption(this.initOptions)
    const echartSeries = []
    const colors = ['#fac858', '#91cc75', '#5470c6', '#9a60b4', '#3ba272', '#D9001B']
    for (let i = 0; i < series.length; i++) {
      echartSeries.push({
        name: series[i].name,
        type: 'bar',
        data: series[i].value,
        color: colors[i],
        label: {
          show: true,
          position: 'top'
        }
      })
    }
    echartObject.setOption({
      xAxis: {
        data: xAxis
      },
      legend: {
        data: legend
      },
      dataZoom: [{
        type: 'inside',
        xAxisIndex: [0],
        startValue: xAxis.length - 7,
        endValue: xAxis.length
      }],
      series: echartSeries
    })
    setTimeout(() => {
      echartObject.resize()
    })
  }
}
